package sdau.hjk.dao;

import sdau.hjk.entity.User;
import sdau.hjk.entity.UserRecord;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

/**
 *@version 1.0
 *@author: huangjiakai
 *@create:2021−02-16 10:23
 *@className:com.hjk.dao.IUserRecordDao
 *@description: TODO
 */
@Repository
public interface IUserRecordDao {
    //根据id查询打卡记录
    @Select("select * from record where id = #{id} order by date desc")
    public List<UserRecord> findById(Integer id);
    //添加打卡记录
    @Insert("insert into record(id,date,temp,site,note) values(#{id},#{date},#{temp},#{site},#{note})")
    public void saveUserRecord(UserRecord userRecord);
    //查询当天备注特殊情况的记录
    @Select("select * from user_record where date = #{date} order by note desc")
    public List<UserRecord> findByNote(Date date);
    //查询当天未打卡用户
    @Select("select * from user where not exists" +
            "(select * from record where id = user.id and date = #{date})" +
            "order by id")
    public List<User> findByNotClock(Date date);
}
